package com.ksm.server.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.ksm.client.document.service.IKsmService;
import com.ksm.server.service.support.AutoinjectingRemoteServiceServlet;
import com.ksm.service.IDocumentService;
import com.ksm.service.IReferentielService;
import com.ksm.transfer.dto.DocumentDTO;
import com.ksm.transfer.dto.DocumentFilterDTO;
import com.ksm.transfer.dto.JustificatifDTO;
import com.ksm.transfer.dto.TvaDTO;
import com.ksm.transfer.dto.TypeDocumentDTO;

public class IKsmServiceImpl extends AutoinjectingRemoteServiceServlet implements IKsmService {

	private static final Logger LOGGER = LoggerFactory.getLogger(IKsmServiceImpl.class);

	@Autowired
	IDocumentService documentService;

	@Autowired
	IReferentielService referentielService;

	private static final long serialVersionUID = 1L;

	public List<DocumentDTO> findDocumentByFilter(DocumentFilterDTO filterDTO) {
		return documentService.findDocumentByFilter(filterDTO);
	}

	public DocumentDTO saveDocument(DocumentDTO documentDTO) {
		DocumentDTO dto = null;
		try {
			dto = documentService.saveDocument(documentDTO);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return dto;
	}

	public JustificatifDTO saveJustificatif(JustificatifDTO justificatifDTO) {
		JustificatifDTO dto = null;
		try {
			dto = documentService.saveJustificatif(justificatifDTO);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return dto;
	}

	public List<TvaDTO> loadTva() {
		return referentielService.loadTva();
	}

	@Override
	public List<TypeDocumentDTO> loadTypeDocument() {
		return referentielService.loadTypeDocument();
	}

}
